Java Programming Strings and Wrappers
This programming assignment is designed to evaluate your knowledge, comprehension and application of Java String and primitive data type Wrapper classes. It is expected that a program can be written that compiles and runs correctly. You should work on this programming assignment on your own. However, collaboration with others on general logic flow, techniques and Java Core API methods available may be useful. It is most beneficial if you do not share code.
Program: Write a Java program that accepts text input from the keyboard, performs the operations specified below. Accept more text input until just the "enter" key is inputted, at that point exit the program. For this program you will need to use the java.lang.String and java.lang.Integer objects and methods associated with each.
12. Display the binary, octal and hex string of the int variable.
Sample screen output during a particular running of the program:
Enter a string of text followed by a comma (,) and an integer value: This is a test, -32
Text: This is a test
Length: 14
Int: -32
Starts with "This"? true
Ends with "test"? true
THIS IS A TEST
this is a test
a
a not equal to A
This is a test. This is the next sentence.
This is a test. –32
is is a te
11111111111111111111111111100000
37777777740
FFFFFFE0
The name of the object must be Ex5. To run the program, the Ex5 Java object is invoked. The Ex5 skeleton source code is presented below and should be used. This source code should be put in a file named Ex5.java and then compiled. When it is compiled the object that is run will be called Ex5.class. The entire program can be implemented in the main method.
IMPORTANT: The file for this program must be named Ex5.java. (Not EX05, ex5, or any other variation). Your file must be should placed in a subdirectory for this project. I suggest something like C:\javacode\Ex5\
Ex5.java code:
import java.io.*; public class Ex5 { Ex5() { } public static void main(String args[]) { BufferedReader console; console = new BufferedReader(new InputStreamReader(System.in)); String intstring = ""; do { try { System.out.print("prompt"); intstring = console.readLine(); } catch (IOException e) { //ignore exception } if (intstring.equals("")) { break; } //insert logic here } while (true); } //end main } //end of Ex5 class